import Vue from 'vue'

import 'normalize.css/normalize.css' // A modern alternative to CSS resets

import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import i18n from '@/lang'
// import locale from 'element-ui/lib/locale/lang/en' // lang i18n

import '@/styles/index.scss' // global css

import App from './App'
import store from './store'
import router from './router'
import request from '@/utils/request'
import '@/icons' // icon
import '@/permission' // permission control
// import { imgerror, color } from '@/directives'
// Vue.use(ElementUI)
// 配置ElementUI的中英切换逻辑
Vue.use(ElementUI, {
  i18n: (key, value) => i18n.t(key, value)
})
// 注册全局组件
// import PageTools from '@/components/PageTools'
// Vue.component('PageTools', PageTools)

// 批量全局注册组件
import Component from '@/components'
Vue.use(Component)

Vue.config.productionTip = false

Vue.prototype.$request = request
// 注册一个全局自定义指令 `v-focus`
// Vue.directive('imgError', imgerror)
// Vue.directive('color', color)
// 批量导入注册自定义事件
import * as directives from '@/directives'
// 批量注册 方式1
// for (const key in directives) {
//   Vue.directive(key, directives[key])
// }
// 批量注册 方式2
Object.keys(directives).forEach((key) => Vue.directive(key, directives[key]))

// 全局批量注册过滤器
import * as filters from '@/filters'
Object.keys(filters).forEach(key => Vue.filter(key, filters[key]))

import Print from 'vue-print-nb'
Vue.use(Print)

new Vue({
  el: '#app',
  router,
  store,
  i18n,
  render: h => h(App)
})
